package io.jee.caisan.weixin.config;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;

import io.jee.caisan.weixin.domain.Member;

@Component
public class SessionManager {
	
	//@Resource
	//private WechatMpProperties properties;

	public void setSession(HttpServletRequest request, String key, Object value) {
		request.getSession().setAttribute(/*properties.getAppId() + */key, value);
	}
	
	public Object getSession(HttpServletRequest request, String key) {
		return request.getSession().getAttribute(/*properties.getAppId() + */key);
	}
	
	public void setSessionOpenid(HttpServletRequest request, String openid) {
		setSession(request, "openid", openid);
	}
	
	public String getSessionOpenid(HttpServletRequest request) {
		return (String) getSession(request, "openid");
	}
	
	public void setSessionMember(HttpServletRequest request, Member member) {
		setSession(request, "member", member);
	}
	
	public Member getSessionMember(HttpServletRequest request) {
		return (Member) getSession(request, "member");
	}
}
